<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('作品统计列表')" />
    <style>
        .select-table table {
            table-layout:fixed;
        }

        .select-table .table td {
            /* 超出部分隐藏 */
            overflow:hidden;
            /* 超出部分显示省略号 */
            text-overflow:ellipsis;
            /*规定段落中的文本不进行换行 */
            white-space:nowrap;
            /* 配合宽度来使用 */
            height:40px;
        }

        .fixed-table-pagination{
            color: red;
        }
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                大赛名称：<select name="gameId" th:with="games=${@gameService.selectGameList(null)}">
                                <option th:each="game : ${games}" th:text="${game.name}" th:value="${game.id}"></option>
                            </select>
                            </li>
                            <li>
                                <label>学校名称：</label>
                                <input type="text" name="school"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:stat:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:stat:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:stat:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:stat:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:stat:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:stat:remove')}]];
        var prefix = ctx + "system/stat";
        var canOperation = [[${canOperation}]]
        if(editFlag == '' && canOperation == false){
            editFlag = 'hidden'
        }
        if(removeFlag == '' && canOperation == false){
            removeFlag = 'hidden'
        }


        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "作品统计",
                showFooter: true,
                pageList:[10, 50,10000],
                // columns: [[
                //     {
                //         title: '销售大区',
                //         align: 'center',
                //         rowspan: 3
                //     }, {
                //         title: '区域',
                //         align: 'center',
                //         rowspan: 3
                //     }, {
                //         title: '经销商',
                //         align: 'center',
                //         rowspan: 3
                //     }, {
                //         title: '期前欠款',
                //         align: 'center',
                //         colspan: 4
                //     }, {
                //         title: '2016年发车数量',
                //         align: 'center',
                //         rowspan: 3
                //     }, {
                //         title: '2016年销售明细',
                //         align: 'center',
                //         colspan: 12
                //     }, {
                //         title: '账上目前预付款',
                //         align: 'center',
                //         rowspan: 3
                //     }, {
                //         title: '截止2016年欠款',
                //         align: 'center',
                //         rowspan: 3
                //     }, {
                //         title: '2016收款',
                //         align: 'center',
                //         rowspan: 3
                //     }
                // ],
                //     [{
                //         field: 'userPhone',
                //         title: '销售发车',
                //         align: "center",
                //         colspan: 3
                //     }, {
                //         field: 'userEmail',
                //         title: '款转为2017年预付款',
                //         align: "center",
                //         rowspan: 2
                //     }, {
                //         field: 'userBalance',
                //         title: '2016年合同货值',
                //         align: "center",
                //         colspan: 3
                //     }, {
                //         field: 'status',
                //         title: '其他费用',
                //         align: "center",
                //         colspan: 3
                //     }, {
                //         title: '代付运费',
                //         align: 'center',
                //         colspan: 3
                //     }, {
                //         title: '2016年货后客户逾期)',
                //         align: 'center',
                //         colspan: 3
                //     }
                //     ],
                //     [{
                //         field: 'userPhone',
                //         align: "center",
                //         title: '应收'
                //     }, {
                //         field: 'userEmail',
                //         align: "center",
                //         title: '实收'
                //     }, {
                //         field: 'userBalance',
                //         align: "center",
                //         title: '欠款'
                //     }, {
                //         field: 'status',
                //         align: "center",
                //         title: '应收'
                //     }, {
                //         align: 'center',
                //         title: '实收'
                //     }, {
                //         field: 'userPhone',
                //         align: "center",
                //         title: '欠款'
                //     }, {
                //         field: 'userEmail',
                //         align: "center",
                //         title: '应收'
                //     }, {
                //         field: 'userBalance',
                //         align: "center",
                //         title: '实收'
                //     }, {
                //         field: 'status',
                //         align: "center",
                //         title: '欠款'
                //     }, {
                //         field: 'status',
                //         align: "center",
                //         title: '应收'
                //     }, {
                //         field: 'userPhone',
                //         align: "center",
                //         title: '实收'
                //     }, {
                //         field: 'userEmail',
                //         align: "center",
                //         title: '欠款'
                //     }, {
                //         field: 'userBalance',
                //         align: "center",
                //         title: '应收'
                //     }, {
                //         field: 'status',
                //         align: "center",
                //         title: '实收'
                //     }, {
                //         field: 'status',
                //         align: "center",
                //         title: '欠款'
                //     }
                //     ]
                // ]
                columns: [[
                {
                    checkbox: true,
                    rowspan: 2
                },
                {
                    field: 'id',
                    title: '',
                    visible: false,
                    rowspan: 2
                },
                // {
                //     field: 'gameName',
                //     title: '大赛名称',
                //     rowspan: 2,
                //     width:200,
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var span=document.createElement('span');
                //         span.setAttribute('title',value);
                //         span.innerHTML = value;
                //         return span.outerHTML;
                //     },
                // },
                {
                    field: 'school',
                    title: '学校名称',
                    rowspan: 2,
                    width:200,
                    align: 'center',
                    formatter: function(value, row, index) {
                        var result = value;
                        var beginChar = result.substring(0,1);
                        if("0123456789".indexOf(beginChar) > -1){
                            var begin = result.substring(0,6);
                            begin = begin.replace(/[0-9|-]/ig,"");
                            result =  begin + result.substring(6);
                        }

                        var span=document.createElement('span');
                        span.setAttribute('title',result);
                        span.innerHTML = result;
                        return span.outerHTML;
                    },
                    footerFormatter:function(data){
                        return '总计'
                    }
                },
                {
                    field: 'faculty',
                    title: '院系名称',
                    rowspan: 2,
                    width:200,
                    align: 'center',
                    formatter: function(value, row, index) {
                        var span=document.createElement('span');
                        span.setAttribute('title',value);
                        span.innerHTML = value;
                        return span.outerHTML;
                    },
                },
                {
                    field: 'deptCode',
                    title: '院校编号',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                }
                , {
                    field:'anum',
                    title:'A 平面类',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },{
                    title:'B 视频类',
                    align: 'center',
                    colspan: 3,
                    width:300,
                    footerFormatter:formatterSum
                },{
                    field:'cnum',
                    title:'C 动画类',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },{
                    field:'dnum',
                    title:'D 互动类',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },{
                    field:'enum',
                    title:'E 广播类',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },{
                    field:'fnum',
                    title:'F 策划案类',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },{
                    title:'G 文案类',
                    align: 'center',
                    colspan: 3,
                    width:300,
                    footerFormatter:formatterSum
                },
                {
                    field: 'submitActNum',
                    title: '报送参评<br/>作品合计',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },
                {
                    field: 'realActNum',
                    title: '参赛院校遴选<br/>前作品数量',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },
                {
                    field: 'submitRate',
                    title: '报送比例',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                },
                {
                    field: 'studentNum',
                    title: '参赛学生人数',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },
                {
                    field: 'teacherNum',
                    title: '指导老师人数',
                    rowspan: 2,
                    width:100,
                    align: 'center',
                    footerFormatter:formatterSum
                },
                {
                    title: '操作',
                    align: 'center',
                    rowspan: 2,
                    width:100,
                    formatter: function(value, row, index) {
                        //var uId = row.gameId + "," + row.schoolId + "," + row.facultyId;
                        console.log(row.gameId + "," + row.schoolId + "," + row.facultyId)
                        var uId = row.gameId + "," + row.schoolId + "," + row.facultyId;
                        return '<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + uId + '\')"><i class="fa fa-edit"></i>编辑</a> ';
                    }
                }
                ],[
                    {
                        field:'baNum',
                        title:'Ba 影视',
                        align: 'center',
                        footerFormatter:formatterSum
                    },{
                        field:'bbNum',
                        title:'Bb 微电影',
                        align: 'center',
                        footerFormatter:formatterSum
                    },{
                        field:'bcNum',
                        title:'Bc 短视频',
                        align: 'center',
                        footerFormatter:formatterSum
                    },{
                        field:'gaNum',
                        title:'Ga 广告语',
                        align: 'center',
                        footerFormatter:formatterSum
                    },{
                        field:'gbNum',
                        title:'Gb 长文案',
                        align: 'center',
                        footerFormatter:formatterSum
                    },{
                        field:'gcNum',
                        title:'Gc 创意脚本',
                        align: 'center',
                        footerFormatter:formatterSum
                    },
                ]]
            };
            $.table.init(options);
        });
        function formatterSum(data){
            var field = this.field
            return data.map(function (row) {
                var temp = row[field] == '-' ? 0 : row[field]
                return +temp
            }).reduce(function (sum, i) {
                return sum + i
            }, 0)
        }
    </script>
</body>
</html>
